package ch.bfh.abcm.rems.sensors.tinkerforge;

import ch.bfh.abcm.rems.exceptions.UnknownDeviceTypeException;

public enum TFSensorType {

        AMBIENT(21,"Lux"),
        BAROMETER(221, "mbar"),
        COLOR(243, "RGB"),
        DISTANCE_IR(25, "mm"),
        DISTANCE_US(229, "cm"),
        HALL_EFFECT(240, "Gauss"),
        HUMIDITY(27, "%"),
        LINE(241, "nm"),
        MOISTURE(232, "mA"),
        MOTION_DETECTOR(233, "1/0"),
        SOUND_INTENSITY(238, "Hüllkurve"),
        TEMPERATURE(216, "°C"), 
        TEMPERATURE_IR(217, "°C"),
        TILT(239, "1/0");
        
    private final String unit;
    private final int deviceIdentifier;

    private TFSensorType(int deviceIdentifier, String unit) {
        this.deviceIdentifier = deviceIdentifier;
        this.unit = unit;
    }

    public int getDeviceIdentifier() {
        return deviceIdentifier;
    }

    public String getUnit() {
        return unit;
    }

    public static TFSensorType getByDeviceIdentifier(int deviceIdentifier) {
        for (TFSensorType type : values()) {
            if (type.getDeviceIdentifier() == deviceIdentifier) {
                return type;
            }
        }
        throw new UnknownDeviceTypeException("TFType with Idendifier " + deviceIdentifier + " not implemented");
    }
}
